package com.zj.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zj.model.Product;
import com.zj.web.bean.ProductDTO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ProductMapper extends BaseMapper<Product> {
    @Select("select p.*,c.categoryName\n" +
            "from product p\n" +
            "left join category c on p.categoryId=c.categoryId\n" +
            "where p.productId=#{productId}")
    @Results({
            //property需要严格对照bean类的信息
            @Result(column = "productId", property = "productId"),
            @Result(column = "categoryId", property = "categoryId"),
            @Result(column = "productName", property = "productName"),
            @Result(column = "productImg", property = "productImg"),
            @Result(column = "description", property = "description"),
            @Result(column = "price", property = "price"),
            @Result(column = "originalPrice", property = "originalPrice"),
            @Result(column = "productStatus", property = "productStatus"),
            @Result(column = "categoryName", property = "categoryName")
    })
    ProductDTO selectProductById(@Param("productId") Long productId);
}
